# Creates a spherical cluster with randomly distributed masses.

import random as random
import numpy as np

rLim = [0.0, 1.0]
thetaLim =[0.0,360.0]
phiLim = [0.0,180.0]

omega = 6.28/3.0 # radians/year.

mLim = [1.0, 100.0]

nBodies=500;

outFile = "cluster.nbd"

random.seed()

def makeRandom(n):
   of = open(outFile, 'w')

   for i in range(nBodies):
      mass = random.uniform(*mLim)

      r = random.uniform(*rLim)
      theta = random.uniform(*thetaLim)
      phi = random.uniform(*phiLim)

      x = r*(np.sin(theta)*np.sin(phi))
      y = r*(np.cos(theta)*np.sin(phi))
      z = r*np.cos(phi)

      st = str(mass) + "," + str(x) + "," + str(y) + "," + str(z) + ","+ str(r*omega*np.sin(theta)) + ","+ str(r*omega*np.cos(theta)) + ","+ str(0.0) + "\n"
      of.write(st);

   of.close()


makeRandom(10);
